// 存储token
export const setItem = (key, val) => {
  // 判断是否为引用数据类型
  if (typeof val === 'object') {
    localStorage.setItem(key, JSON.stringify(val))
  } else {
    localStorage.setItem(key, val)
  }
}

// 获取token
export const getItem = (key) => {
  const data = localStorage.getItem(key)
  try {
    return JSON.parse(data)
  } catch (error) {
    return data
  }
}

// 获取token
export const removeItem = (key) => {
  const data = localStorage.removeItem(key)
  try {
    return JSON.parse(data)
  } catch (error) {
    return data
  }
}
